package com.hqyj.module.leave.controller;

import com.github.pagehelper.PageInfo;
import com.hqyj.module.leave.pojo.Result;


import com.hqyj.module.leave.pojo.HolidayInfo;
import com.hqyj.module.leave.pojo.SearchBean;
import com.hqyj.module.leave.service.HolidayInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：hyj
 * @description：leaveInfoController
 * @date ：2021/9/28 15:29
 */

@RestController
@RequestMapping("/leave")
public class HolidayController {

    @Autowired
    HolidayInfoService holidayInfoService;

    @GetMapping("/holidayInfo")
    public HolidayInfo getHolidayInfo(Integer userId){
        return holidayInfoService.getHolidayInfo(userId);
    }

    @GetMapping(value = "/allHolidayInfo")
    public PageInfo<HolidayInfo> getAllHolidayInfo(SearchBean searchBean){
        return holidayInfoService.getAllHolidayInfo(searchBean);
    }

    @GetMapping(value = "/addHolidayInfo",consumes = "application/json;charset=UTF-8")
    public Result<HolidayInfo> insertHoliday(HolidayInfo holidayInfo){
        return holidayInfoService.insertHolidayInfo(holidayInfo);
    }

    @GetMapping(value = "/leaderAddHolidayInfo",consumes = "application/json;charset=UTF-8")
    public Result<HolidayInfo> leaderInsertHoliday(HolidayInfo holidayInfo){
        return holidayInfoService.leaderUpdateHolidayInfo(holidayInfo);
    }

    @DeleteMapping("/deleteHolidayInfo/{id}")
    @RequiresPermissions("/leave/deleteHolidayInfo/{id}")
    public Result<Object> deleteHolidayInfo(@PathVariable int id){
        return holidayInfoService.deleteHolidayInfo(id);
    }

    @GetMapping(value="/updateHolidayInfo",consumes="application/json;charset=UTF-8")
    public Result<HolidayInfo> updateHolidayInfo(HolidayInfo holidayInfo){
        return holidayInfoService.updateHolidayInfo(holidayInfo);
    }
}
